<?php
session_start();
require "lib/db.php";
require "lib/category-function.php";
require "lib/subcategory-function.php";

if(isset($_POST['btnAddSubCategory'])){
	$subCategoryName = $_POST['txtSubCategoryName'];
	$categoryID = $_POST['cbCategoryName'];
	settype($categoryID,"int");
	$description = $_POST['taDescription'];
	addSubCategory($subCategoryName,$description,$categoryID);
	header("location:list-subcategory.php");
}

if(isset($_POST['btnEditSubCategory'])){
	$subCategoryName = $_POST['txtSubCategoryName'];
	$categoryID = $_POST['cbCategoryName'];
	settype($categoryID,"int");
	$description = $_POST['taDescription'];
	$subCategoryID = $_POST['hfSubCategoryID'];
	editSubCategory($subCategoryName,$description,$categoryID,$subCategoryID);
	header("location:list-subcategory.php");
}
?>